package cn.momoshenchi.controller;

import cn.momoshenchi.ResultInfo;
import cn.momoshenchi.pojo.Student;
import cn.momoshenchi.pojo.StudentResume;
import cn.momoshenchi.service.StudentResumeService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;

/**
 * @version : 1.0
 * @author: momoshenchi
 * @date: 2021/4/20 - 14:40
 */
@Controller
@Api("简历信息")
public class StudentResumeController
{
    @Autowired
    private StudentResumeService studentResumeService;

    public  ResultInfo success()
    {
        return  new ResultInfo();
    }

    @Operation(summary="通过学号查询某个学生简历")
    @GetMapping("studentResume/student/{studentId}")
    @ResponseBody
    public Map<String, Object> selectByStudentId(@PathVariable String studentId)
    {
       return studentResumeService.selectByStudentId(studentId);
    }
    @Operation(summary="添加学生简历")
    @PostMapping("studentResume")
    @PreAuthorize("hasAuthority('student:add')")
    @ResponseBody
    public ResultInfo add(@Valid @RequestBody StudentResume studentResume)
    {
        studentResumeService.add(studentResume);
        return  success();
    }
    @Operation(summary="修改学生简历")
    @PreAuthorize("hasAuthority('student:update')")
    @PutMapping("studentResume")
    @ResponseBody
    public ResultInfo update( @RequestBody StudentResume studentResume)
    {
        studentResumeService.update(studentResume);
        return  success();
    }
    @Operation(summary="通过主键删除学生简历")
    @DeleteMapping("studentResume/{id}")
    @PreAuthorize("hasAuthority('student:delete')")
    @ResponseBody
    public ResultInfo delete(@PathVariable  Integer id)
    {
        studentResumeService.delete(id);
        return  success();
    }

    @Operation(summary="通过主键查询学生简历")
    @GetMapping("studentResume/{id}")
    @ResponseBody
    public Map<String, Object>  selectById(@PathVariable  Integer id)
    {
       return studentResumeService.selectById(id);
    }
}
